<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>lesson 30</title>
    <style>
        .area {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            width: 300px;
            height: 200px;
            background: orange;
        }

        .mask {
            position: absolute;
            left: 0;
            right: 0;
            top: 0.5;
            bottom: 0;
            background: blue;
            opacity: 1;
            color: #fff;
            font-size: 20px;
        }
    </style>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="app"></div>
    <div id="hello"></div>
</body>
<script>
    // teleport 传送门
    //场景：我们需要实现一个蒙层，这个蒙层需要吧整个body笼罩住？但是现在只能笼罩在中间的橙色区域上，效果运行可见。
    const app = Vue.createApp({
        data() {
            return {
                show: false,
            }
        },
        methods: {
            handleBtnClick() {
                this.show = !this.show;
            }
        },
        template: `
            <div class="area">
                <button @click="handleBtnClick">按钮</button>
                <teleport to="#hello">
                    <div class="mask" v-show="show"></div>
                </teleport>
                <div class="mask" v-show="show"></div>
            </div>
        `
    });

    const vm = app.mount('#app');
</script>

</html>